<META http-equiv=Content-Type content="text/html;charset=utf-8">
<!--== Start Footer Area ==-->
    <!-- Footer Widget Area Start -->
    <div class="footer-widget-area">
        <div class="container">
            <div class="footer-widget-content">
                <div class="row">
                    <!-- Single Widget-item Start -->
                    <div class="col-lg-3 col-sm-6">
                        <div class="single-widget-item">
                            <h3 class="widget-title">About Market</h3>
                            <div class="widget-body">
                                <ul class="footer-list">
                                    <li><a href="#">My Account</a></li>
                                    <li><a href="#">Order History</a></li>
                                    <li><a href="#">Returns</a></li>
                                    <li><a href="#">Specials</a></li>
                                    <li><a href="#">Site Map</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <!-- Single Widget-item End -->

                    <!-- Single Widget-item Start -->
                    <div class="col-lg-3 col-sm-6">
                        <div class="single-widget-item">
                            <h3 class="widget-title">Customer Service</h3>
                            <div class="widget-body">
                                <ul class="footer-list">
                                    <li><a href="#">Returns</a></li>
                                    <li><a href="#">Order History</a></li>
                                    <li><a href="#">My Account</a></li>
                                    <li><a href="#">Site Map</a></li>
                                    <li><a href="#">Specials</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <!-- Single Widget-item End -->

                    <!-- Single Widget-item Start -->
                    <div class="col-lg-3 col-sm-6">
                        <div class="single-widget-item">
                            <h3 class="widget-title">Information</h3>
                            <div class="widget-body">
                                <ul class="footer-list">
                                    <li><a href="#">Order History</a></li>
                                    <li><a href="#">Site Map</a></li>
                                    <li><a href="#">Returns</a></li>
                                    <li><a href="#">Specials</a></li>
                                    <li><a href="#">My Account</a></li>
                                </ul>
                            </div>
                        </div>
                    </div>
                    <!-- Single Widget-item End -->

                    <!-- Single Widget-item Start -->
                    <div class="col-lg-3 col-sm-6">
                        <div class="single-widget-item">
                            <h3 class="widget-title">Contact Us</h3>
                            <div class="widget-body">
                                <div class="contact-info">
                                    <div class="single-contact-info">
                                    <span class="contact-icon">
                                        <i class="fa fa-home"></i>
                                    </span>
                                        <a href="mailto:your@example.com" class="contact-text">
                                            <strong>Address:</strong> 15/C, Uttara, Dhaka
                                        </a>
                                    </div>
                                    <div class="single-contact-info">
                                    <span class="contact-icon">
                                        <i class="fa fa-phone"></i>
                                    </span>
                                        <a href="mailto:your@example.com" class="contact-text">
                                            <strong>Phone:</strong> (+1) 866-540-3229
                                        </a>
                                    </div>
                                    <div class="single-contact-info">
                                    <span class="contact-icon">
                                        <i class="fa fa-envelope"></i>
                                    </span>
                                        <a href="mailto:your@example.com" class="contact-text">
                                            <strong>Email:</strong> your@email.here
                                        </a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- Single Widget-item End -->
                </div>
            </div>
        </div>
    </div>
    <!-- Footer Widget Area End -->

    <!-- Footer Bottom Area -->
    <div class="footer-bttom-area">
        <div class="container">
            <div class="row">
                <!-- Copyright Text Area -->
                <div class="col-md-6 m-auto text-center text-md-left order-last order-md-first">
                    <p>Copyright &copy; 2018.Company name All rights reserved.<a target="_blank" href="http://sc.chinaz.com/moban/">&#x7F51;&#x9875;&#x6A21;&#x677F;</a></p>
                </div>
                <!-- Copyright Text Area -->

                <!-- Payment Method Area -->
                <div class="col-md-6 m-auto text-center text-md-right">
                    <div class="payment-support">
                        <img src="assets/img/payment.png" alt="Payment" class="d-inline-block" />
                    </div>
                </div>
                <!-- Payment Method Area -->
            </div>
        </div>
    </div>
    <!-- Footer Bottom Area -->
<!--== End Footer Area ==-->
<script type="text/javascript">
    var user_id;
	$.getJSON("user/doGetUsername",function(result){
		console.log(result);
		$(".login_name").html("欢迎用户:" + result.data.username);
		$(".login_name").attr("href","doLogout");
		user_id = result.data.id;
	});
	
	
	$(document).ready(function(){
		$("#minicart-wrapper").on("click","#btn-minicart",loadCart);
		showslicknav();
	});
	
	
	function loadCart(){
		console.log(user_id);
		if(user_id == null){
			location.href="doLoginUI";
		}else{
			var param = {
				id:user_id
			}
			$.getJSON("Cart/getList",param,function(result){
				console.log(result);
				loadCartitem(result.data);
				$(".cart-count").html(result.message);
			});
		}
	}
	
	function loadCartitem(data){
		var tbody = $(".mini-cart-body");
		tbody.empty();
		for(var i in data){
			var p = createitem(data[i]);
			tbody.append(p);
		}
	}
	
	function createitem(item){
		var p = "<div class='single-cart-item d-flex'>"+
				"<figure class='product-thumb'>"+
				"<a href='single-product.html'><img"+
				" src='assets/imageResource/"+item.imgUrl+"' alt='Products' /></a>" +
				"</figure>"+
				"<div class='product-details'>" +
				"<h2><a href='single-product.html'>"+item.specs_info+"</a></h2>"+
				"<div class='cal d-flex align-items-center'>"+
				"<span class='quantity'>"+item.count+"</span> <span class='multiplication'>X</span>"+
				"<span class='price'>¥"+item.price+"</span>"+
				"</div>"+
				"</div>"+
				"<a class='remove-icon' onclick='deleteCart("+item.cart_id+")'><i class='fa fa-trash-o'></i></a>"
		return p;
	}
	
	function deleteCart(cid){
		var param = {
			id:cid
		}
		$.getJSON("Cart/deleteCartsByCartId",param,function(result){
			if(result.state==1){
				alert("删除成功");
				loadCart();
			}
		});
	}

	function showslicknav(){
		$.getJSON("Cate/getIndexCate",function(result){
			console.log(result);
			loadnav(result.data);
		});
	}
	
	function loadnav(data){
		var tbody = $(".category-list-menu");
		tbody.empty();
		var brandList = data.brandsList;
		var firstCate = data.firstCate;
		var secondCate = data.secondCate;
		for(var i in firstCate){
			var li = "<li class='category-item-parent dropdown-show'>";
			var li2 = "<li class='category-item-parent'>";
			var countul = 0;
			var a = "<a href='shop?type=category&id="+firstCate[i].id+"&page=1' class='category-item arrow-toggle'> <img src='assets/img/icons/desktop.png'  /> <span>"+firstCate[i].category_name+"</span></a>";
			//li += a + "</li>";
			a+="<ul class='mega-menu-wrap dropdown-nav'>";
			for(var j in secondCate){
				if(firstCate[i].id == secondCate[j].category_parent){
					countul++;
					var count = 0;
					var k =
					"<li class='mega-menu-item'><a href='shop?type=category&id="+secondCate[j].id+"&page=1' class='mega-item-title'>"+secondCate[j].category_name+"</a>"+
					"<ul>";
					for(var z in brandList){
						if(secondCate[j].id == brandList[z].category_id){
							k += "<li><a href='shop?type=brand&id="+brandList[z].id+"&page=1''>"+brandList[z].brand_name+"</a></li>";
							count++;
						}
					}
					k+="</ul>";
					k+="</li>";
					if(count != 0){
						a += k;
					}
				}
			}
			a+="</ul>";
			if(countul == 0){
				li2 += a;
				tbody.append(li2);
			}else{
				li += a;
				tbody.append(li);
			}
		}
	}
	
	
	
	
	/* <ul class="category-list-menu">
		<li class="category-item-parent dropdown-show">
		<a href="#"
			class="category-item arrow-toggle"> <img
				src="assets/img/icons/desktop.png" alt="Computer" /> <span>Computer</span>
		</a>
			<ul class="mega-menu-wrap dropdown-nav">
				<li class="mega-menu-item"><a href="#"
					class="mega-item-title">Laptop</a>
					<ul>
						<li><a href="#">Has Laptop Price</a></li>
						<li><a href="#">Has Laptop Ram</a></li>
						<li><a href="#">Has Laptop Rom</a></li>
						<li><a href="#">Has Laptop SSD</a></li>
					</ul>
				</li>
			</ul>
		</li>
	</ul> */
</script>
